//
//  HWMeiRiRenWuViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/10/9.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWMeiRiRenWuViewController.h"
#import "HWXingShouTableViewCell.h"
#import "HWXingShouModel.h"



@interface HWMeiRiRenWuViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(strong,nonatomic) UITableView *mainaTableVie;
@property(strong,nonatomic) NSMutableArray *dataMuAr;
@end

@implementation HWMeiRiRenWuViewController

-(UITableView *)mainaTableVie {

    if (_mainaTableVie == nil
        ) {


        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(15, 165+CF_StatusBarHeight-20, kScreenW-30,58*4) style:UITableViewStylePlain];
         _mainaTableVie.delegate = self;
         _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
        

    }
    return   _mainaTableVie ;
}



- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

   // [self.navigationController setNavigationBarHidden:YES animated:animated];
     [self.navigationController setNavigationBarHidden:YES ];
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

  //  [self.navigationController setNavigationBarHidden:NO animated:animated];
     [self.navigationController setNavigationBarHidden:NO ];
}


//- (void)viewWillAppear:(BOOL)animated{
//    [super viewWillAppear:animated];
//    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
//    //去掉导航栏底部的黑线
//  //  self.navigationController.navigationBar.shadowImage = [UIImage new];
//}
////如果仅设置当前页导航透明，需加入下面方法
//- (void)viewWillDisappear:(BOOL)animated{
//    [super viewWillDisappear:animated];
//    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
//    [self.navigationController.navigationBar setShadowImage:nil];
//}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setCommonProperties];
    
    [self setupUI];
}

// 设置常用的属性
- (void)setCommonProperties {
//
//    @property(strong,nonatomic)NSString *icoStr;
//    @property(strong,nonatomic)NSString *biaoTiStrin;
//    @property(strong,nonatomic)NSString *miaoshuStr;
//    @property(strong,nonatomic)NSString *zhuataiStr; // 是进行中吗


     
//     @{@"icoStr":@"welfare_message_per",@"biaoTiStrin":@"修改头像",@"miaoshuStr":@"+10积分",@"zhuataiStr":@"1"};
//
  //  HWXingShouModel *mdeol = [[HWXingShouModel alloc]init];
    NSArray *arr = @[@{@"icoStr":@"mess_signin",@"biaoTiStrin":@"每日签到",@"miaoshuStr":@"+1积分",@"zhuataiStr":@"1"},@{@"icoStr":@"mess_m",@"biaoTiStrin":@"评论奖励",@"miaoshuStr":@"+10积分",@"zhuataiStr":@"1"},@{@"icoStr":@"mess_day",@"biaoTiStrin":@"每日分享",@"miaoshuStr":@"+10积分",@"zhuataiStr":@"2"},@{@"icoStr":@"mess_charge",@"biaoTiStrin":@"每日充值",@"miaoshuStr":@"+10积分",@"zhuataiStr":@"1"}];
 //   self.dataMuAr  =  [HWXingShouModel mj_keyValuesArrayWithObjectArray:arr];
    self.dataMuAr = [HWXingShouModel mj_objectArrayWithKeyValuesArray:arr];
    
    
}



- (void)setupUI {
    
     self.view.backgroundColor = RGB(242, 242, 242);
     [self setUPbeijingView];
     [self navigaView];
     [self addtablview];
     

}

- (void)addtablview {
    
    self.mainaTableVie.layer.cornerRadius = 3;
    self.mainaTableVie.layer.masksToBounds = YES;
    self.mainaTableVie.scrollEnabled = NO;
    [self.view addSubview:self.mainaTableVie];
    
}


- (void)setUPbeijingView {
    
    UIView *beijingView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 165+CF_StatusBarHeight)];
    beijingView.backgroundColor = RGB(242, 242, 242);
     
    [self.view addSubview:beijingView];
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 165+CF_StatusBarHeight)];
    imageView.image = [UIImage imageNamed:@"welfare_bg"];
    [beijingView addSubview:imageView];
    
     
     UIImageView *jingxiang = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenW-149-10, 165+CF_StatusBarHeight-124+5, 149, 124)];
     jingxiang.image = [UIImage imageNamed:@"welfare_message_m"];
    // jingxiang.backgroundColor = [UIColor yellowColor];
     
     [imageView addSubview:jingxiang];
    
     UIImageView *renwujifenwenziimageview = [[UIImageView alloc]initWithFrame:CGRectMake((kScreenW-147*CFLScaleValue-149-10)/2, 165+CF_StatusBarHeight-50*CFLScaleValue-40, 147*CFLScaleValue, 50*CFLScaleValue)];
     renwujifenwenziimageview.image = [UIImage imageNamed:@"welfare_message_tit"];
    // renwujifenwenziimageview.backgroundColor = [UIColor redColor];
     [imageView addSubview:renwujifenwenziimageview];
        


}

- (void)navigaView  {
    
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
    
   
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(10,StatusBarHeight+17, 40, 17);
   // button.backgroundColor = [UIColor redColor];
    [button setImage:[UIImage imageNamed:@"details_back"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonTap) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:button];
    
    UILabel *textlabel = [[UILabel alloc]initWithFrame:CGRectMake((kScreenW-70)/2, StatusBarHeight+17, 70, 17)];
    textlabel.text = @"新手任务";
    textlabel.textAlignment =  NSTextAlignmentCenter;
    textlabel.textColor = [UIColor whiteColor];
    textlabel.font = [UIFont systemFontOfSize:16];
    [self.view addSubview:textlabel];
    
    
    
    
}




#pragma  mark -------- UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    return self.dataMuAr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"cellID";
    
    HWXingShouTableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

    
    if (!cell) {
        cell =   [[NSBundle mainBundle]loadNibNamed:@"HWXingShouTableViewCell" owner:nil options:nil].firstObject;
    }
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
    cell.backgroundColor  = [UIColor whiteColor];
    HWXingShouModel      *model =     self.dataMuAr[indexPath.row];
    cell.icoimageView.image = [UIImage imageNamed:model.icoStr];
    cell.zhuBiaotilabel.text = model.biaoTiStrin;
    cell.cibiaotiLabel.text = model.miaoshuStr;
    if ([model.zhuataiStr isEqualToString:@"1"]) {
        
        cell.lingquBut.backgroundColor = blueBackgroundBT;
         
        [cell.lingquBut setTitle:@"进行中" forState:UIControlStateNormal];
        
        
    } else if ([model.zhuataiStr isEqualToString:@"2"]) {
        
      //  cell.lingquBut.backgroundColor = RGB(212, 212, 212);
        cell.lingquBut.backgroundColor = blueBackgroundBT;
     //   cell.lingquBut
        
        [cell.lingquBut setTitle:@"进行中" forState:UIControlStateNormal];
        
    }
    
    
    

    return  cell;
    
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    return  58;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    

    
    if (indexPath.row == 0 ) {
        
        
    } else if (indexPath.row == 1) {
        
     
    }
    
    
    
}


- (void)buttonTap {
    
    [self.navigationController popViewControllerAnimated:YES];
}

@end
